<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<SubsidiosBussinessLogic.Models.Funcionario>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Listar
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>Listado funcionarios</h2>

 
  
<script type="text/javascript">
  var bloques = $.ajax(
                        {url:'/Bloque/GetBloques/',async: false, 
                     success: function(data, result) 
                   {
                        if (!result) 
                        alert('Error al recibir los bloques');
                        
                   }
                    }
                    ).responseText;
    var tipoFuncionarios = $.ajax(
                        {url:'/TipoFuncionario/GetTipoFuncionarios/',async: false, 
                     success: function(data, result) 
                   {
                        if (!result) 
                        alert('Error al recibir los bloques');
                        
                   }
                    }
                    ).responseText;
    jQuery(document).ready(function(){ 
      jQuery("#list").jqGrid({
        url:'/Funcionario/GridData/',
        datatype: 'json',
        mtype: 'GET',
        colNames:['FuncionarioId','Bloque','Tipo Funcionario','RazonSocial'],
        colModel :[
          {name:'FuncionarioId', index:'FuncionarioId', width:120, align:'left',editrules: { edithidden: true,  editable: false},searchoptions:{sopt:['eq','cn']} },
          //{ name: 'BloqueId', index: 'BloqueId', width: 100, editrules: { edithidden: true,editable: true}, searchoptions:{sopt:['eq','cn']} },
          { name: 'BloqueId', index: 'BloqueId', width: 130, editable: true,editrules: { edithidden: false,hidden:false}, edittype: "select", editoptions: { size: 70} },
           { name: 'TipoFuncionarioId', index: 'TipoFuncionarioId', width: 130, editable: true,editrules: { edithidden: false,hidden:false}, edittype: "select", editoptions: { size: 70} },
          {name:'RazonSocial', index:'RazonSocial', width:700, align:'left', editable: true, edittype: 'text', editoptions: { size: 20, maxlength: 30},searchoptions:{sopt:['eq','cn']} }
         ],
        
        loadComplete: function()
        {
            jQuery('#list').setColProp('BloqueId', {editoptions: {value: bloques}});
            jQuery('#list').setColProp('TipoFuncionarioId', {editoptions: {value: tipoFuncionarios}});
        },

        pager: jQuery('#pager'),
        rowNum:10,
        rowList:[5,10,20,50],
        sortname: 'BloqueId',
        sortorder: "asc",
        viewrecords: true,
        jsonReader: { repeatitems : true, id: "0" },
        imgpath: '/Scripts/themes/redmond/images',
        height : '100%',
        caption: 'Funcionarios',

       
        
      }).navGrid('#pager', {edit:true, add:true,search:true}, //options 
        {
           
            height:150,
            reloadAfterSubmit:false,
            closeOnEscape:true, 
            url:'/Funcionario/GridataSave/',
            resize:false,
            checkOnSubmit:true,
            checkOnUpdate:true,
            closeAfterEdit:true,
            savekey:[true,13],
            modal:true,
            afterSubmit : checkCallBack                 

        }, // edit options 
        {
            
            reloadAfterSubmit:true,
            closeOnEscape:true, 
            url:'/Funcionario/GridataAdd/',
            resize:false,
            clearAfterAdd:true,
            savekey:[true,13],
            modal:true,
            width:'auto',
            height:'auto',
            afterSubmit : checkCallBack
                     
        }, // add options 
        {
            width:300,  
            reloadAfterSubmit:true,
            closeOnEscape:true, 
            url:'/Bloque/GridataDelete/',
            resize:false,
            checkOnSubmit:true,
            modal:true,
            afterSubmit : checkCallBack
                        
        }, // del options 
            
        { 
            
            
          
        }, // search options 
        {
        }
        );  
        function checkCallBack (r, d) 
                          {
                                return [r.responseText=="", r.responseText];
                          }
    }); 
</script>

<table id="list" class="scroll" cellpadding="0" cellspacing="0" Width="100%" style ="text-align:center"  >

</table>
<div id="pager" class="scroll" style="text-align:center;"></div>

    <p>
        <%= Html.ActionLink("Crear", "Crear") %>
    </p>

</asp:Content>

